//自定义图片放大
;(function($){  
	$.fn.debigger=function(params){
		var tobigger = params.multiple;
		var tobiggerimgs = $(this);
		if(params.type){
			if("2" == params.type){
				//内增大
				tobiggerimgs.mouseover(function(e){
					var thisimg = $(this);
					var left = thisimg.offset().left;
					var top = thisimg.offset().top;
					var width = thisimg.width();
					var height = thisimg.height();
					var tlcenter = left + width/2;
					var tleft = (1-tobigger)*width/2;
					var ttcenter = top + height/2;
					var ttop = (1-tobigger)*height/2;
					thisimg.css("opacity",0);
					var tindex = tobiggerimgs.index(this);
					var thisimgclasses = thisimg.attr("class");
					var appendimg = $("<div style='overflow: hidden;z-index:10001;position:absolute;left:"+left+"px;top:"+top+"px;width:"+width+"px;height: "+height+"px'><img class='tobiggerimgsx"+tindex+" "+thisimgclasses+"' src='"+$(this).attr("src")+"' style='position:absolute;left:0px;top:0px;width:"+width+"px;height:"+height+"px;max-width:none;'/></div>");
					$("body").append(appendimg);
					$(".tobiggerimgsx"+tindex).animate({left:tleft+'px',top:ttop+'px',width:width*tobigger+'px',height:height*tobigger+'px'},'fast');
					$(".tobiggerimgsx"+tindex).mouseleave(function(e){
						$(".tobiggerimgsx"+tindex).animate({left:'0px',top:'0px',width:width+'px',height:height+'px'},'fast',function(){
							$(this).parent().remove();
							thisimg.css("opacity",1);
						});
					});
					$(".tobiggerimgsx"+tindex).click(function(){
						thisimg.click();
					});
				});
			}else if("3" == params.type){
				//内增大
				tobiggerimgs.bind("click",function(e){
					var thisimg = $(this);
					var left = thisimg.offset().left;
					var top = thisimg.offset().top;
					var width = thisimg.width();
					var height = thisimg.height();
					thisimg.css("opacity",0);
					var tindex = tobiggerimgs.index(this);
					var thisimgclasses = thisimg.attr("class");
					var appendimg = $("<div class='tobiggerimgsx"+tindex+"' style='overflow: hidden;z-index:10001;position:absolute;left:"+left+"px;top:"+top+"px;width:"+width+"px;height: "+height+"px'><img class='"+thisimgclasses+"' src='"+$(this).attr("src")+"' style='position:absolute;left:0px;top:0px;width:100%;height:100%px;max-width:none;'/></div>");
					$("body").append(appendimg);
					$(".tobiggerimgsx"+tindex).animate({left:'0px',top:'0px',width:'100%',height:'100%'},'fast');
					$(".tobiggerimgsx"+tindex).bind("click",function(e){
						$(this).remove();
						thisimg.css("opacity",1);
					});
					$(".tobiggerimgsx"+tindex).mouseleave(function(e){
						$(this).remove();
						thisimg.css("opacity",1);
					});
					$(".tobiggerimgsx"+tindex).click(function(){
						thisimg.click();
					});
				});
			}
		}else{
			tobiggerimgs.mouseover(function(e){
				var thisimg = $(this);
				var left = thisimg.offset().left;
				var top = thisimg.offset().top;
				var width = thisimg.width();
				var height = thisimg.height();
				var tlcenter = left + width/2;
				var tleft = tlcenter-(tobigger*width/2);
				var ttcenter = top + height/2;
				var ttop = ttcenter-(tobigger*height/2);
				thisimg.css("opacity",0);
				var tindex = tobiggerimgs.index(this);
				var thisimgclasses = thisimg.attr("class");
				var appendimg = $("<img class='tobiggerimgsx"+tindex+" "+thisimgclasses+"' src='"+$(this).attr("src")+"' style='z-index:10001;position:absolute;left:"+left+"px;top:"+top+"px;width:"+width+"px;height:"+height+"px;'/>");
				$("body").append(appendimg);
				$(".tobiggerimgsx"+tindex).animate({left:tleft+'px',top:ttop+'px',width:width*tobigger+'px',height:height*tobigger+'px'},'fast');
				$(".tobiggerimgsx"+tindex).mouseleave(function(e){
					$(".tobiggerimgsx"+tindex).animate({left:left+'px',top:top+'px',width:width+'px',height:height+'px'},'fast',function(){
						$(this).remove();
						thisimg.css("opacity",1);
					});
				});
				$(".tobiggerimgsx"+tindex).click(function(){
					thisimg.click();
				});
			});
		}
	}
})(jQuery); 